package com.lk.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.lk.model.domain.Post;
import com.lk.model.domain.User;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

/**
* @author LK
* @description 针对表【user(用户)】的数据库操作Mapper
* @Entity com.lk.model.domain.User
*/
public interface PostMapper extends BaseMapper<Post> {

    List<Post> selectAll();

    @Select("select * from post where id = #{postId}")
    Post getById(Long postId);

   @Update("update post set followsIds = #{followsIds} ,followsNum = #{followsNum} where id = #{id}")
    int addLikeToDataBase(@Param("id") Long id,@Param("followsIds") String followsIds, @Param("followsNum") int followsNum);

   @Select("select commentIds from post where id = #{postId}")
   String getCommentDetail(Long postId);

   @Update("update post set commentIds =#{json} where id = #{postId}")
   int addComment(@Param("postId") Long postId,@Param("json") String json);

   @Update("update post set commentNum = #{size} where id = #{postId}")
    void updateCommentNum(@Param("postId") Long postId,@Param("size") int size);
}




